CFGTYPES_SRCS = cfgtypes.c
CFGTYPES_OBJS = $(CFGTYPES_SRCS:.c=.o)

UNICODE_TRAIT_SRCS = unicode_trait.c
UNICODE_TRAIT_OBJS = $(UNICODE_TRAIT_SRCS:.c=.o)

UNICODE_CASE_SRCS = unicode_case.c
UNICODE_CASE_OBJS = $(UNICODE_CASE_SRCS:.c=.o)

CC = @CC@
CFLAGS = @CFLAGS@ -I@abs_top_builddir@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
DEFS = @DEFS@

all: cfgtypes unicode_trait unicode_case
	
cfgtypes: $(CFGTYPES_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(CFGTYPES_OBJS) $(LIBS)

unicode_trait: $(UNICODE_TRAIT_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(UNICODE_TRAIT_OBJS) $(LIBS)

unicode_case: $(UNICODE_TRAIT_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(UNICODE_TRAIT_OBJS) $(LIBS)

gen_table: unicode_trait unicode_case
	./ctype_unicode_trait > ../xp/c/ctype_unicode_trait.c
	./ctype_unicode_case > ../xp/c/ctype_unicode_case.c
	#echo "#ifndef _XP_XPTYPES_H_" > ../xp/xp_types.h
	#echo "#define _XP_XPTYPES_H_" >> ../xp/xp_types.h
	#./cfgtypes xp_ >> ../xp/xp_types.h
	#echo "#endif" >> ../xp/xp_types.h

clean:
	rm -rf $(CFGTYPES_OBJS) cfgtypes *.o ../xp/xp_types.h

.SUFFIXES: .c .o
.c.o:
	$(CC) $(CFLAGS) $(DEFS) -c $<
